﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataProcessParameter" @search="()=>{getTableDataProcessParameter();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RouteId_FormItem" prop="RouteId" :label="$t('message.autotrans._Model_ProcessParameter_Route')">
            <el-select v-model="searchDataProcessParameter.RouteId" clearable>
               <el-option v-for="item in stateProcessParameter.AllRoutes" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpId_FormItem" prop="OpId" :label="$t('message.autotrans._Model_ProcessParameter_Op')">
            <el-select v-model="searchDataProcessParameter.OpId" clearable>
               <el-option v-for="item in stateProcessParameter.AllOps" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TagId_FormItem" prop="TagId" :label="$t('message.autotrans._Model_ProcessParameter_TagId')">
            <el-input v-model="searchDataProcessParameter.TagId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TagName_FormItem" prop="TagName" :label="$t('message.autotrans._Model_ProcessParameter_TagName')">
            <el-input v-model="searchDataProcessParameter.TagName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SetValue_FormItem" prop="SetValue" :label="$t('message.autotrans._Model_ProcessParameter_SetValue')">
            <el-input v-model="searchDataProcessParameter.SetValue" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Precision_FormItem" prop="Precision" :label="$t('message.autotrans._Model_ProcessParameter_Precision')">
            <el-input v-model="searchDataProcessParameter.Precision" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ParameterName_FormItem" prop="ParameterName" :label="$t('message.autotrans._Model_ProcessParameter_ParameterName')">
            <el-input v-model="searchDataProcessParameter.ParameterName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DataType_FormItem" prop="DataType" :label="$t('message.autotrans._Model_ProcessParameter_DataType')">
            <el-select v-model="searchDataProcessParameter.DataType" clearable>
               <el-option key="Sys_Bit" value="Sys_Bit" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Bit')"></el-option>
               <el-option key="Sys_Byte" value="Sys_Byte" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Byte')"></el-option>
               <el-option key="Sys_Word" value="Sys_Word" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Word')"></el-option>
               <el-option key="Sys_DWork" value="Sys_DWork" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_DWork')"></el-option>
               <el-option key="Sys_Int" value="Sys_Int" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Int')"></el-option>
               <el-option key="Sys_DInt" value="Sys_DInt" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_DInt')"></el-option>
               <el-option key="Sys_Real" value="Sys_Real" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_Real')"></el-option>
               <el-option key="Sys_LReal" value="Sys_LReal" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_LReal')"></el-option>
               <el-option key="Sys_String" value="Sys_String" :label="$t('message.autotrans._Enum_TagDataTypeEnum_Sys_String')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Active_FormItem" prop="Active" :label="$t('message.autotrans._Model_ProcessParameter_Active')">
            <el-select v-model="searchDataProcessParameter.Active" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ProcessParameter_CreateTime')">
            <el-date-picker v-model="searchDataProcessParameter.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ProcessParameter_UpdateTime')">
            <el-date-picker v-model="searchDataProcessParameter.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ProcessParameter_CreateBy')">
            <el-input v-model="searchDataProcessParameter.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ProcessParameter_UpdateBy')">
            <el-input v-model="searchDataProcessParameter.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/ProcessManagement/ProcessParameter/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessParameter/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessParameter/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessParameter/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessParameter/ProcessParameterExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefProcessParameter" v-bind="tableDataProcessParameter">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/ProcessManagement/ProcessParameter/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProcessManagement/ProcessParameter/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProcessManagement/ProcessParameter/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProcessManagementProcessParameterIndex;true;Digitalmes.ProcessManagement.Controllers;ProcessParameter">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { processparameterApi } from '/@/api/processmanagement/processparameter';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateProcessParameter = reactive({
    
    AllRoutes: [] as any[],
    AllOps: [] as any[],
});

const searchDataProcessParameter = ref({
        RouteId: null,
        OpId: null,
        TagId: null,
        TagName: '',
        SetValue: '',
        Precision: null,
        ParameterName: '',
        DataType: undefined,
        Active: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefProcessParameter = ref();
const tableDataProcessParameter = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page工艺路线'),key: 'ProcessParameter_Route',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工序'),key: 'ProcessParameter_Op',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page变量'),key: 'ProcessParameter_TagId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page变量名称'),key: 'ProcessParameter_TagName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page设定值'),key: 'ProcessParameter_SetValue',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page精度'),key: 'ProcessParameter_Precision',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page参数名称'),key: 'ProcessParameter_ParameterName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据类型'),key: 'ProcessParameter_DataType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page激活'),key: 'ProcessParameter_Active',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ProcessParameter_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ProcessParameter_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ProcessParameter_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ProcessParameter_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataProcessParameter = () => {
    tableRefProcessParameter.value.doSearch(processparameterApi().search, searchDataProcessParameter.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataProcessParameter)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataProcessParameter)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataProcessParameter)
};

// 删除
const onDelete = (row: any) => {
    processparameterApi().delete([row.ID]).then(() => { getTableDataProcessParameter()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefProcessParameter.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      processparameterApi().delete(selectedids).then(() => { getTableDataProcessParameter()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefProcessParameter.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataProcessParameter)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataProcessParameter)
};

const onExport = () => {
	const selected = tableRefProcessParameter.value.getSelectedRows();
	if (selected.length > 0) {
		processparameterApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		processparameterApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/ProcessManagement/ProcessParameter/GetProcessRoutes',[],false).then(x=>{stateProcessParameter.AllRoutes = x});
    other.getSelectList('/api/ProcessManagement/ProcessParameter/GetProcessRouteItems',[],false).then(x=>{stateProcessParameter.AllOps = x});
        getTableDataProcessParameter();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

